﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using TMS.Bll;
using TMS.Dal;
using TMS.Model;

namespace TMS.UI.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class MemberController : ControllerBase
    {
        public MemberController(Membll membll)
        {
            Membll = membll;
        }

        public Membll Membll { get; }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        /// 
        [HttpGet("Login")]
        public IActionResult Login(string name, string pwd)
        {
            try
            {
                var res= Membll.Login(name, pwd);
                return Ok(new
                {
                    data = res,
                });
            }
            catch (Exception)
            {

                throw;
            }

        }
       
        /// <summary>
        /// 显示加查询
        /// </summary>
        /// <param name="name"></param>
        /// <param name="age"></param>
        /// <returns></returns>
        /// 
        [HttpGet("GetMembers")]
        public IActionResult GetMembers(string? name, string? age)
        {
            try
            {
                var res= Membll.GetMembers(name, age);
                return Ok(new
                {
                    data = res
                });
            }
            catch (Exception)
            {

                throw;
            }

        }
    }
}
